﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataReworkData" @search="()=>{getTableDataReworkData();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="WoId_FormItem" prop="WoId" :label="$t('message.autotrans._Model_ReworkData_WoId')">
            <el-input v-model="searchDataReworkData.WoId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="WoCode_FormItem" prop="WoCode" :label="$t('message.autotrans._Model_ReworkData_WoCode')">
            <el-input v-model="searchDataReworkData.WoCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductId_FormItem" prop="ProductId" :label="$t('message.autotrans._Model_ReworkData_ProductId')">
            <el-input v-model="searchDataReworkData.ProductId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductName_FormItem" prop="ProductName" :label="$t('message.autotrans._Model_ReworkData_ProductName')">
            <el-input v-model="searchDataReworkData.ProductName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Sn_FormItem" prop="Sn" :label="$t('message.autotrans._Model_ReworkData_Sn')">
            <el-input v-model="searchDataReworkData.Sn" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ReTypeId_FormItem" prop="ReTypeId" :label="$t('message.autotrans._Model_ReworkData_ReType')">
            <el-select v-model="searchDataReworkData.ReTypeId" clearable>
               <el-option v-for="item in stateReworkData.AllReTypes" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ReTypeDesc_FormItem" prop="ReTypeDesc" :label="$t('message.autotrans._Model_ReworkData_ReTypeDesc')">
            <el-input v-model="searchDataReworkData.ReTypeDesc" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ReasonName_FormItem" prop="ReasonName" :label="$t('message.autotrans._Model_ReworkData_ReasonName')">
            <el-input v-model="searchDataReworkData.ReasonName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ReasonCode_FormItem" prop="ReasonCode" :label="$t('message.autotrans._Model_ReworkData_ReasonCode')">
            <el-input v-model="searchDataReworkData.ReasonCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Remark_FormItem" prop="Remark" :label="$t('message.autotrans._Model_ReworkData_Remark')">
            <el-input v-model="searchDataReworkData.Remark" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Operation_FormItem" prop="Operation" :label="$t('message.autotrans._Model_ReworkData_Operation')">
            <el-input v-model="searchDataReworkData.Operation" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Data_FormItem" prop="Data" :label="$t('message.autotrans._Model_ReworkData_Data')">
            <el-input v-model="searchDataReworkData.Data" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateTime_FormItem" prop="CreateTime" :label="$t('message.autotrans._Model_ReworkData_CreateTime')">
            <el-date-picker v-model="searchDataReworkData.CreateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateTime_FormItem" prop="UpdateTime" :label="$t('message.autotrans._Model_ReworkData_UpdateTime')">
            <el-date-picker v-model="searchDataReworkData.UpdateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateBy_FormItem" prop="CreateBy" :label="$t('message.autotrans._Model_ReworkData_CreateBy')">
            <el-input v-model="searchDataReworkData.CreateBy" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateBy_FormItem" prop="UpdateBy" :label="$t('message.autotrans._Model_ReworkData_UpdateBy')">
            <el-input v-model="searchDataReworkData.UpdateBy" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/ReworkManagement/ReworkData/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/ReworkManagement/ReworkData/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/ReworkManagement/ReworkData/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/ReworkManagement/ReworkData/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/ReworkManagement/ReworkData/ReworkDataExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefReworkData" v-bind="tableDataReworkData">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
            <WtmButton v-auth="'/api/ReworkManagement/ReworkData/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/ReworkManagement/ReworkData/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/ReworkManagement/ReworkData/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageReworkManagementReworkDataIndex;true;Digitalmes.ReworkManagement.Controllers;ReworkData">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { reworkdataApi } from '/@/api/reworkmanagement/reworkdata';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateReworkData = reactive({
    
    AllReTypes: [] as any[],
});

const searchDataReworkData = ref({
        WoId: null,
        WoCode: '',
        ProductId: null,
        ProductName: '',
        Sn: '',
        ReTypeId: null,
        ReTypeDesc: '',
        ReasonName: '',
        ReasonCode: '',
        Remark: '',
        Operation: '',
        Data: '',
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
});

// 定义变量内容
const tableRefReworkData = ref();
const tableDataReworkData = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page工单号'),key: 'ReworkData_WoId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工单编码'),key: 'ReworkData_WoCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产品'),key: 'ReworkData_ProductId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产品名称'),key: 'ReworkData_ProductName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page追溯码'),key: 'ReworkData_Sn',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page返工类型'),key: 'ReworkData_ReType',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page返工描述'),key: 'ReworkData_ReTypeDesc',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page原因名称'),key: 'ReworkData_ReasonName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page原因编码'),key: 'ReworkData_ReasonCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminRemark'),key: 'ReworkData_Remark',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page操作员'),key: 'ReworkData_Operation',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page返工数据'),key: 'ReworkData_Data',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateTime'),key: 'ReworkData_CreateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateTime'),key: 'ReworkData_UpdateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateBy'),key: 'ReworkData_CreateBy',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateBy'),key: 'ReworkData_UpdateBy',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminIsValid'),key: 'ReworkData_IsValid',type: 'switch',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataReworkData = () => {
    tableRefReworkData.value.doSearch(reworkdataApi().search, searchDataReworkData.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataReworkData)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataReworkData)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataReworkData)
};

// 删除
const onDelete = (row: any) => {
    reworkdataApi().delete([row.ID]).then(() => { getTableDataReworkData()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefReworkData.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      reworkdataApi().delete(selectedids).then(() => { getTableDataReworkData()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefReworkData.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataReworkData)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataReworkData)
};

const onExport = () => {
	const selected = tableRefReworkData.value.getSelectedRows();
	if (selected.length > 0) {
		reworkdataApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		reworkdataApi().export({});
	}
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/ReworkManagement/ReworkData/GetReworkTypes',[],false).then(x=>{stateReworkData.AllReTypes = x});
        getTableDataReworkData();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

